/**
 * @param {Egg.Application} app - egg application
 */
module.exports = app => {
  const { router, controller, io } = app;
  const getIp = app.middleware.ip({})
  const checkSign = app.middleware.checkSign({}, app)

  // 轩哥的狗机子上传
  router.get('/gjz', controller.home.index);
  router.post('/upload', controller.home.upload);

  // 博客评论区
  router.post('/blog/comment/send', getIp, controller.blog.sendComment)
  router.get('/blog/comment/get', checkSign, controller.blog.getComments)
  router.get('/blog/gamerom/log', getIp, controller.blog.gameRomLog)

  // 忘了要干啥了，好像是网站统计
  router.get('/statistic/nginx/list', controller.blog.nginxStatisticList)
  router.get('/statistic/nginx/detail', controller.blog.nginxStatisticDetail)
  
  // 米家游戏mod管理器
  router.get('/mmm/allInOne', controller.mmm.allInOne)

  // 栾影雪的日历
  router.get('/xue_calendar/', getIp, controller.xueCalendar.index)
  router.get('/xue_calendar/dashboard', controller.xueCalendar.dashboard)
  router.post('/xue_calendar/upload', controller.xueCalendar.upload)
  router.get('/xue_calendar/delete', controller.xueCalendar.del)

  // 栾影雪的日历 小程序版本
  // 用户端
  router.get('/xue_calendar/wxLogin', getIp, controller.xueCalendar.wxLogin)
  router.post('/xue_calendar/bindCode', getIp, controller.xueCalendar.bindCode)
  router.get('/xue_calendar/mpGetImageList', getIp, controller.xueCalendar.mpGetImageList)

  // 管理端
  router.get('/xue_calendar/getLunar', controller.xueCalendar.getLunar)
  router.post('/xue_calendar/addCodes', controller.xueCalendar.addCodes)
  router.get('/xue_calendar/getCodes', controller.xueCalendar.getCodes)
  router.get('/xue_calendar/getList', controller.xueCalendar.getList)
  router.get('/xue_calendar/userList', controller.xueCalendar.userList)
  router.get('/xue_calendar/logList', controller.xueCalendar.logList)
  router.get('/xue_calendar/statistic', controller.xueCalendar.statistic)
  router.post('/xue_calendar/recCode', controller.xueCalendar.recCode)
  router.post('/xue_calendar/recUserCode', controller.xueCalendar.recUserCode)
  router.post('/xue_calendar/delCode', controller.xueCalendar.delCode)
  router.get('/xue_calendar/xueMpConfig', controller.xueCalendar.xueMpConfig)
  router.post('/xue_calendar/updateUser', controller.xueCalendar.updateUser)
  router.get('/xue_calendar/genQr', controller.xueCalendar.genQr)

  // 看门狗

  const watchDogCheckUser = app.middleware.mpCheckOpenid({userTable: 'watchdog_user'}, app)
  router.get('/watchdog/wxLogin', getIp, controller.watchdog.wxLogin)
  router.post('/watchdog/addHome', watchDogCheckUser, getIp, controller.watchdog.addHome)
  router.post('/watchdog/delHome', watchDogCheckUser, getIp, controller.watchdog.delHome)
  router.get('/watchdog/getMyHomes', watchDogCheckUser, getIp, controller.watchdog.getMyHomes)
  router.get('/watchdog/getHomeQr', watchDogCheckUser, getIp, controller.watchdog.getHomeQr)
  router.post('/watchdog/addGood', watchDogCheckUser, getIp, controller.watchdog.addGood)
  router.get('/watchdog/getGoods', watchDogCheckUser, getIp, controller.watchdog.getGoods)
  // @todo
  router.get('/watchdog/getHome', getIp, controller.watchdog.wxLogin)
  // @todo
  // @todo
  // @todo
  router.post('/watchdog/commitArrive', getIp, controller.watchdog.wxLogin)

  // 芥末记账
  const doriCheckUser = app.middleware.mpCheckOpenid({userTable: 'dori_user'}, app)
  router.get('/dori/wxLogin', getIp, controller.dori.wxLogin)
  router.get('/dori/getUserInfo', getIp, doriCheckUser, controller.dori.getUserInfo)
  router.get('/dori/getCategorys', getIp, doriCheckUser, controller.dori.getCategorys)

  router.get('/goods/', getIp, controller.goods.index)
  router.get('/goods/dashboard', getIp, controller.goods.dashboard)
  router.post('/goods/upload', getIp, controller.goods.upload)

  // one 镜像
  router.get('/oneisall/', controller.oneisall.index)
  router.get('/oneisall/sync', controller.oneisall.runCrontabTaskManual)
}
